#region imported Namespaces
using System;
using System.Data;

using SplitConstants = PHSRAG.Insight21.Personnel.Constants.DistributionSplitsConstants;
#endregion

namespace PHSRAG.Insight21.Personnel
{
	#region DistributionSplit class
	/// <summary>
	///  The DistributionSplit class is the facade over the details for a single distribution split.
	/// </summary>
	public class DistributionSplit
	{
		#region Instance Variables
		private DataRow splitRow;
		#endregion

		#region Public Properties
		/// <summary>
		/// Get the ID of the distribution split
		/// </summary>
		public int SplitID
		{
			get
			{
				return (int)splitRow[SplitConstants.SplitIDColumnName];
			}
		}
		/// <summary>
		/// Get the ID of the salary distribution to which the split is associated to
		/// </summary>
		public int SalaryDistributionID
		{
			get
			{
				return (int)splitRow[SplitConstants.SalaryDistributionIDColumnName];
			}
		}
		/// <summary>
		/// Get the ID of the salary adjustment to which the split is associated to
		/// </summary>
		public int SalaryAdjustmentID
		{
			get
			{
				return (int)splitRow[SplitConstants.SalaryAdjustmentIDColumnName];
			}
		}
		/// <summary>
		/// Get the perecent effort
		/// Return 0 if there is no percent effort for the split
		/// </summary>
		public decimal PercentEffort
		{
			get
			{
				object percentEffort = splitRow[SplitConstants.PercentEffortColumnName];
				return (percentEffort == DBNull.Value)?0:(decimal)percentEffort;
			}
		}
		/// <summary>
		/// Get the annual rate
		/// Return 0 if there is no annual rate for the split
		/// </summary>
		public decimal AnnualRate
		{
			get
			{
				object annualRate = splitRow[SplitConstants.AnnualRateColumnName];
				return (annualRate == DBNull.Value)?0:(decimal)annualRate;
			}
		}
		/// <summary>
		/// Get the split effective date
		/// Return an empty string if there is no effective date for the split
		/// </summary>
		public string EffectiveDate
		{
			get
			{
				object effectiveDate = splitRow[SplitConstants.EffectiveDateColumnName];
				return (effectiveDate == DBNull.Value)?
					string.Empty:((DateTime)effectiveDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the split expiration date
		/// Return an empty string if there is no expiration date for the split
		/// </summary>
		public string ExpirationDate
		{
			get
			{
				object expirationDate = splitRow[SplitConstants.ExpirationDateColumnName];
				return (expirationDate == DBNull.Value)?
					string.Empty:((DateTime)expirationDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the To be paid amount for the split
		/// Return 0 if there is no to be paid amount
		/// </summary>
		public decimal ToBePaid
		{
			get
			{
				object toBePaid = splitRow[SplitConstants.ToBePaidColumnName];
				return (toBePaid == DBNull.Value)?0:(decimal)toBePaid;
			}
		}
		/// <summary>
		/// Get the fund number to which the split is associated to
		/// Return an empty string is there is no fund number for the split
		/// </summary>
		public string FundNumber
		{
			get
			{
				object fundNumber = splitRow[SplitConstants.FundNumberColumnName];
				return (fundNumber == DBNull.Value)?string.Empty:fundNumber.ToString();
			}
		}
		/// <summary>
		/// Get the project title for the split
		/// Return an empty string if there is no project title
		/// </summary>
		public string ProjectTitle
		{
			get
			{
				object projectTitle = splitRow[SplitConstants.TitleColumnName];
				return (projectTitle==DBNull.Value)?string.Empty:projectTitle.ToString();
			}
		}
		/// <summary>
		/// Get the user name who last edited the distribution to which the split is associated
		/// Return an empty string if there is no value in the editedby column
		/// </summary>
		public string EditedBy
		{
			get
			{
				object editedBy = splitRow[SplitConstants.EditedByColumnName];
				return (editedBy==DBNull.Value)?string.Empty:editedBy.ToString();
			}
		}
		/// <summary>
		/// Get the last edit date for the distribution to which the split is associated to
		/// Return an empty string if there is no value in the edit date column
		/// </summary>
		public string EditDate
		{
			get
			{
				object editDate = splitRow[SplitConstants.EditDateColumnName];
				return (editDate==DBNull.Value)?string.Empty:((DateTime)editDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the budget start date for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string BudgetStartDate
		{
			get
			{
				object budgetStartDate = splitRow[SplitConstants.BudgetStartDateColumnName];
				return (budgetStartDate==DBNull.Value)
					?string.Empty:((DateTime)budgetStartDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the budget end date for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string BudgetEndDate
		{
			get
			{
				object budgetEndDate = splitRow[SplitConstants.BudgetEndDateColumnName];
				return (budgetEndDate==DBNull.Value)
					?string.Empty:((DateTime)budgetEndDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the project start date for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string ProjectStartDate
		{
			get
			{
				object projectStartDate = splitRow[SplitConstants.ProjectStartDateColumnName];
				return (projectStartDate==DBNull.Value)
					?string.Empty:((DateTime)projectStartDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the project end date for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string ProjectEndDate
		{
			get
			{
				object projectEndDate = splitRow[SplitConstants.ProjectEndDateColumnName];
				return (projectEndDate==DBNull.Value)
					?string.Empty:((DateTime)projectEndDate).ToString("MM/dd/yyyy");
			}
		}
		/// <summary>
		/// Get the sponsor number for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string SponsorNumber
		{
			get
			{
				object sponsorNumber = splitRow[SplitConstants.SponsorNumberColumnName];
				return (sponsorNumber == DBNull.Value)?string.Empty:sponsorNumber.ToString();
			}
		}
		/// <summary>
		/// Get the sponsor name for the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string SponsorName
		{
			get
			{
				object sponsorName = splitRow[SplitConstants.SponsorNameColumnName];
				return (sponsorName == DBNull.Value)?string.Empty:sponsorName.ToString();
			}
		}
		/// <summary>
		/// Get the fund category of the associated fund
		/// Return an empty string if there is no value in the DB
		/// </summary>
		public string FundCategory
		{
			get
			{
				object fundCategory = splitRow[SplitConstants.FundCatergoryColumnName];
				return (fundCategory == DBNull.Value)?string.Empty:fundCategory.ToString();
			}
		}
		#endregion

		#region Constructor
		/// <summary>
		/// Set the dataRow to the local instance
		/// </summary>
		/// <param name="dataRow">DataRow containing distribution split data</param>
		public DistributionSplit(DataRow dataRow)
		{
			splitRow = dataRow;
		}
		#endregion
	}
	#endregion
}